package pl.wr.physics.units.quantum.number;

import pl.wr.physics.exceptions.QuantumException;
import pl.wr.physics.units.AbstractUnit;
import pl.wr.physics.units.SI.Prefix;
import pl.wr.physics.units.quantum.QuantumUnit;

public class SpinQuantumNumber implements QuantumUnit {

    public final static SpinQuantumNumber ONE_HALF = new SpinQuantumNumber(0.5f);
    public final static SpinQuantumNumber MINUS_ONE_HALF = new SpinQuantumNumber(-0.5f);

    private float ms;

    public SpinQuantumNumber(float ms) {
        checkScope(ms);
        this.ms = ms;
    }

    public float getMs() {
        return ms;
    }

    public void setMs(float ms) {
        checkScope(ms);
        this.ms = ms;
    }

    private static void checkScope(float ms) {
        if (ms == -0.5 || ms == 0.5) {
            // is OK
        } else {
            throw new QuantumException("Bad scope of number: " + ms);
        }
    }

    @Override
    public AbstractUnit getSIValue() {
        return new AbstractUnit(Prefix.basic, ms, null) {
        };
    }

}
